package flc.ast.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;

import com.bumptech.glide.Glide;

import flc.ast.BaseAc;
import flc.ast.R;
import flc.ast.databinding.ActivityPreviewBinding;

public class PreviewActivity extends BaseAc<ActivityPreviewBinding> {

    public static boolean isCamera = false;
    public static Bitmap resultImg;//拍照结果
    public static String resultPath;//图片详情

    @Override
    protected int onCreate() {
        return R.layout.activity_preview;
    }

    @Override
    protected void initView() {
        mDataBinding.ivPreviewBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        mDataBinding.ivMakeStart.setOnClickListener(this);
    }

    @Override
    protected void onClickCallback(View v) {
        switch (v.getId()){
            case R.id.ivMakeStart:
                ResultActivity.isCamera=isCamera;
                ResultActivity.resultPath=resultPath;
                ResultActivity.resultImg=resultImg;
                startActivity(ResultActivity.class);
                break;
        }
    }

    @Override
    protected void initData() {
        if (isCamera) {
            mDataBinding.ivPreviewImg.setImageBitmap(resultImg);
        } else {
            Glide.with(mContext).load(resultPath).into(mDataBinding.ivPreviewImg);
        }
    }
}